<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理页面</title>
<link href="{webroot}theme/admin/css/iframe.css" rel="stylesheet" type="text/css" />
<link href="{webroot}lib/css/jquery.colorpicker.css" rel="stylesheet" type="text/css" />
<link href="{webroot}lib/css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
<script src="{webroot}lib/js/jquery.js"></script>
<script src="{webroot}lib/js/jquery-migrate-1.1.0.min.js"></script>
<script src="{webroot}lib/js/base.js"></script>
<script src="{webroot}lib/tips/jquery.tips.js"></script>
<script src="{webroot}lib/validator/jquery.validator.js"></script>
<script src="{webroot}lib/validator/zh_CN.js"></script>
<script src="{webroot}lib/js/jquery.livequery.js"></script>
<script src="{webroot}lib/js/jquery.colorpicker.js"></script>
<script src="{webroot}lib/js/jquery.autocomplete.js"></script>
<script src="{webroot}theme/admin/js/admin.js"></script>
<script src="{webroot}lib/dialog/artdialog.js"></script>
<!--[if lt IE 9]>
<script src="{webroot}lib/js/html5.js"></script>
<![endif]-->
<script>
window.UEDITOR_HOME_URL="{webroot}";
var editor_cid="";
var editor_classid="";
var editor_upload_root="";
var editor_adminid="";
var editor_loginbase="";
var editor_loginkey="";
</script>
<script src="{webroot}lib/ueditor/editor_config.js"></script>
<script src="{webroot}lib/ueditor/editor.js"></script>
<script>
$(function()
	{
		UE.getEditor('t4',editorOption_other);
		$("#t0_1").click(function(){$("#group_item").css("display","none");$("#user_item").css("display","none")});
		$("#t0_2").click(function(){$("#group_item").css("display","block");$("#user_item").css("display","none")});
		$("#t0_3").click(function(){$("#group_item").css("display","none");$("#user_item").css("display","block")});
		$("#username").autocomplete("?act=tip",{
		max:10,
		minChars:0,
		width:197,
		scrollHeight:300,
		autoFill:false
	});
	}
)
</script>
</head>
<body>

<div class="layout-center">
	<div class="right_subject">当前位置：会员 > <a href="?">消息管理</a> > <a href="?act=add">发送消息</a></div>
    <div class="right_body">
        <div class="table_form">
            <form class="formname" method="post">
                <div class="form_group">
                    <div class="form_txt">发送方式：</div>
                    <div class="form_input">
                    <input type="radio" name="t0" value="1" id="t0_1" data-rule="发送方式:checked;" /><label for="t0_1">全部会员</label>
           <input type="radio" name="t0" value="2" id="t0_2" /><label for="t0_2">按会员组</label>
           <input type="radio" name="t0" value="3" id="t0_3" /><label for="t0_3">单个会员</label></div>
                </div>
                <div class="form_group">
                    <div class="form_txt">消息类型：</div>
                    <div class="form_input">
                    <input type="radio" name="t5" value="1" id="t5_1" checked="checked" /><label for="t5_1">发站内信</label>
                    <input type="radio" name="t5" value="2" id="t5_2" {if len(mailarr)=0}disabled{/if} /><label for="t5_2">发邮件</label>　<span>开启了邮件设置的组件才能使用"发邮件"</span></div>
                </div>
                <div class="form_group dis" id="group_item">
                    <div class="form_txt">会员组：</div>
                    <div class="form_input"><select name="t1" size="5" multiple="multiple" class="tt" style="width:200px;">
           <option value="0">未分组会员</option>
           {sdcms:rs top="0" table="sd_user_group"}
           <option value="{$rs[id]}">{$rs[groupname]}</option>
           {/sdcms:rs}
           </select></div>
                </div>
                <div class="form_group dis" id="user_item">
                    <div class="form_txt">会员名：</div>
                    <div class="form_input"><input type="text" name="t2" id="username" size="30" maxlength="20" class="ip" data-rule="用户名:required;" /></div>
                </div>
                <div class="form_group">
                    <div class="form_txt">标题：</div>
                    <div class="form_input"><input type="text" name="t3" size="50" maxlength="50" class="ip" data-rule="标题:required;" /></div>
                </div>
                <div class="form_group">
                    <div class="form_txt">内容：</div>
                    <div class="form_input"><textarea name="t4" id="t4" cols="60" rows="8" style="width:96%;"></textarea></div>
                </div>
                <div class="form_group">
                    <div class="form_bnt"><input type="submit" value="执行" class="bnt_save"><input type="button" value="返回" class="bnt_normal goback"></div>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
$(".formname").validator(
	{
		stopOnError:true,
        theme:'yellow_top',
		ignore:':hidden',
		beforeSubmit:function(){$("input[type='submit']").attr("disabled",true);},
		valid:function(form)
		{
			$("#t4").val(UE.getEditor('t4').getContent());
			$.fn.tips({type:'loading',content:'数据提交中'});
			$.ajax(
			{
				url:"?act=db",
				type:"post",
				data:$(form).serialize(),
				success:function(data){
					var act=data.substring(0,1);
					var info=data.substring(1);
					switch(act)
					{
						case "0":
							$.fn.tips({type:"error",content:info});
							$("input[type='submit']").attr("disabled",false);
							break;
						case "1":
							$.fn.tips({type:"ok",content:info});
							break;
						case "2":
							$.fn.tips({type:"ok",content:"信息量过大，正在群发"});
							var arr=info.split(":");
							var total=arr[0];
							var types=arr[1];
							setTimeout("location.href='?act=send&total="+total+"&types="+types+"'",1000);
							break;
						default:
							alert(_)
							break;
					}					
				}
			});
		},
		invalid:function(){$("input[type='submit']").attr("disabled",false);}
	}
);
</script>
</body>
</html>